/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('hsm', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ActiveClusterRequest {
  clusterId?: string(name='ClusterId'),
}

model ActiveClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model ActiveClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ActiveClusterResponseBody(name='body'),
}

async function activeClusterWithOptions(request: ActiveClusterRequest, runtime: Util.RuntimeOptions): ActiveClusterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ActiveCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function activeCluster(request: ActiveClusterRequest): ActiveClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return activeClusterWithOptions(request, runtime);
}

model AddInstancesToClusterRequest {
  clusterId?: string(name='ClusterId'),
  hsmInstanceIds?: map[string]any(name='HsmInstanceIds'),
}

model AddInstancesToClusterShrinkRequest {
  clusterId?: string(name='ClusterId'),
  hsmInstanceIdsShrink?: string(name='HsmInstanceIds'),
}

model AddInstancesToClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model AddInstancesToClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddInstancesToClusterResponseBody(name='body'),
}

async function addInstancesToClusterWithOptions(tmpReq: AddInstancesToClusterRequest, runtime: Util.RuntimeOptions): AddInstancesToClusterResponse {
  Util.validateModel(tmpReq);
  var request = new AddInstancesToClusterShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.hsmInstanceIds)) {
    request.hsmInstanceIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.hsmInstanceIds, 'HsmInstanceIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.hsmInstanceIdsShrink)) {
    query['HsmInstanceIds'] = request.hsmInstanceIdsShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AddInstancesToCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addInstancesToCluster(request: AddInstancesToClusterRequest): AddInstancesToClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return addInstancesToClusterWithOptions(request, runtime);
}

model ConfigAuditLogRequest {
  auditAction?: string(name='AuditAction'),
  configOssBucket?: string(name='ConfigOssBucket'),
  regionNo?: string(name='RegionNo'),
}

model ConfigAuditLogResponseBody = {
  requestId?: string(name='RequestId'),
}

model ConfigAuditLogResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigAuditLogResponseBody(name='body'),
}

async function configAuditLogWithOptions(request: ConfigAuditLogRequest, runtime: Util.RuntimeOptions): ConfigAuditLogResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.auditAction)) {
    query['AuditAction'] = request.auditAction;
  }
  if (!Util.isUnset(request.configOssBucket)) {
    query['ConfigOssBucket'] = request.configOssBucket;
  }
  if (!Util.isUnset(request.regionNo)) {
    query['RegionNo'] = request.regionNo;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigAuditLog',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configAuditLog(request: ConfigAuditLogRequest): ConfigAuditLogResponse {
  var runtime = new Util.RuntimeOptions{};
  return configAuditLogWithOptions(request, runtime);
}

model ConfigClusterMasterRequest {
  clusterId?: string(name='ClusterId'),
  instanceId?: string(name='InstanceId'),
}

model ConfigClusterMasterResponseBody = {
  requestId?: string(name='RequestId'),
}

model ConfigClusterMasterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigClusterMasterResponseBody(name='body'),
}

async function configClusterMasterWithOptions(request: ConfigClusterMasterRequest, runtime: Util.RuntimeOptions): ConfigClusterMasterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigClusterMaster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configClusterMaster(request: ConfigClusterMasterRequest): ConfigClusterMasterResponse {
  var runtime = new Util.RuntimeOptions{};
  return configClusterMasterWithOptions(request, runtime);
}

model ConfigNetworkRequest {
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
  ip?: string(name='Ip', example='192.168.1.100'),
  lang?: string(name='Lang'),
  regionId?: string(name='RegionId'),
  vSwitchId?: string(name='VSwitchId', example='vsw-u7gb0qahu'),
  vpcId?: string(name='VpcId', example='vpc-lmkmivmo6'),
}

model ConfigNetworkResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigNetworkResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigNetworkResponseBody(name='body'),
}

async function configNetworkWithOptions(request: ConfigNetworkRequest, runtime: Util.RuntimeOptions): ConfigNetworkResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ip)) {
    query['Ip'] = request.ip;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchId)) {
    query['VSwitchId'] = request.vSwitchId;
  }
  if (!Util.isUnset(request.vpcId)) {
    query['VpcId'] = request.vpcId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigNetwork',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configNetwork(request: ConfigNetworkRequest): ConfigNetworkResponse {
  var runtime = new Util.RuntimeOptions{};
  return configNetworkWithOptions(request, runtime);
}

model ConfigNewClusterWithInstanceRequest {
  ifTrial?: boolean(name='IfTrial'),
  regionNo?: string(name='RegionNo'),
  vpcId?: string(name='VpcId'),
  vsmType?: string(name='VsmType'),
  vswitchId?: string(name='VswitchId'),
  zoneId?: string(name='ZoneId'),
}

model ConfigNewClusterWithInstanceResponseBody = {
  clusters?: [ 
    {
      certificates?: {
        clusterCertificate?: string(name='ClusterCertificate'),
        clusterCsr?: string(name='ClusterCsr'),
        clusterOwnerCertificate?: string(name='ClusterOwnerCertificate'),
      }(name='Certificates'),
      clusterId?: string(name='ClusterId'),
      clusterMaster?: string(name='ClusterMaster'),
      clusterName?: string(name='ClusterName'),
      clusterSize?: string(name='ClusterSize'),
      clusterStatus?: string(name='ClusterStatus'),
      clusterZones?: [ 
        {
          vSwitchId?: string(name='VSwitchId'),
          zoneNo?: string(name='ZoneNo'),
        }
      ](name='ClusterZones'),
      createTime?: long(name='CreateTime'),
      hsmDeviceType?: string(name='HsmDeviceType'),
      ipWhiteList?: [ string ](name='IpWhiteList'),
      regionId?: string(name='RegionId'),
      vpcId?: string(name='VpcId'),
    }
  ](name='Clusters'),
  requestId?: string(name='RequestId'),
  totalCount?: string(name='TotalCount'),
}

model ConfigNewClusterWithInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigNewClusterWithInstanceResponseBody(name='body'),
}

async function configNewClusterWithInstanceWithOptions(request: ConfigNewClusterWithInstanceRequest, runtime: Util.RuntimeOptions): ConfigNewClusterWithInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ifTrial)) {
    query['IfTrial'] = request.ifTrial;
  }
  if (!Util.isUnset(request.regionNo)) {
    query['RegionNo'] = request.regionNo;
  }
  if (!Util.isUnset(request.vpcId)) {
    query['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.vsmType)) {
    query['VsmType'] = request.vsmType;
  }
  if (!Util.isUnset(request.vswitchId)) {
    query['VswitchId'] = request.vswitchId;
  }
  if (!Util.isUnset(request.zoneId)) {
    query['ZoneId'] = request.zoneId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigNewClusterWithInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configNewClusterWithInstance(request: ConfigNewClusterWithInstanceRequest): ConfigNewClusterWithInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return configNewClusterWithInstanceWithOptions(request, runtime);
}

model ConfigWhiteListRequest {
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
  lang?: string(name='Lang'),
  regionId?: string(name='RegionId'),
  whiteList?: string(name='WhiteList', example='192.168.1.100,192.168.1.0/24'),
}

model ConfigWhiteListResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigWhiteListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigWhiteListResponseBody(name='body'),
}

async function configWhiteListWithOptions(request: ConfigWhiteListRequest, runtime: Util.RuntimeOptions): ConfigWhiteListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.whiteList)) {
    query['WhiteList'] = request.whiteList;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigWhiteList',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configWhiteList(request: ConfigWhiteListRequest): ConfigWhiteListResponse {
  var runtime = new Util.RuntimeOptions{};
  return configWhiteListWithOptions(request, runtime);
}

model ConfigureClusterRequest {
  clusterId?: string(name='ClusterId'),
  clusterName?: string(name='ClusterName'),
  ipWhiteList?: string(name='IpWhiteList'),
  regionId?: string(name='RegionId'),
  vSwitchIds?: [ string ](name='VSwitchIds'),
  vpcId?: string(name='VpcId'),
  zoneNos?: [ string ](name='ZoneNos'),
}

model ConfigureClusterShrinkRequest {
  clusterId?: string(name='ClusterId'),
  clusterName?: string(name='ClusterName'),
  ipWhiteList?: string(name='IpWhiteList'),
  regionId?: string(name='RegionId'),
  vSwitchIdsShrink?: string(name='VSwitchIds'),
  vpcId?: string(name='VpcId'),
  zoneNosShrink?: string(name='ZoneNos'),
}

model ConfigureClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model ConfigureClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConfigureClusterResponseBody(name='body'),
}

async function configureClusterWithOptions(tmpReq: ConfigureClusterRequest, runtime: Util.RuntimeOptions): ConfigureClusterResponse {
  Util.validateModel(tmpReq);
  var request = new ConfigureClusterShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.vSwitchIds)) {
    request.vSwitchIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.vSwitchIds, 'VSwitchIds', 'json');
  }
  if (!Util.isUnset(tmpReq.zoneNos)) {
    request.zoneNosShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.zoneNos, 'ZoneNos', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.clusterName)) {
    query['ClusterName'] = request.clusterName;
  }
  if (!Util.isUnset(request.ipWhiteList)) {
    query['IpWhiteList'] = request.ipWhiteList;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchIdsShrink)) {
    query['VSwitchIds'] = request.vSwitchIdsShrink;
  }
  if (!Util.isUnset(request.vpcId)) {
    query['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.zoneNosShrink)) {
    query['ZoneNos'] = request.zoneNosShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigureCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configureCluster(request: ConfigureClusterRequest): ConfigureClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return configureClusterWithOptions(request, runtime);
}

model CreateClusterRequest {
  clusterName?: string(name='ClusterName'),
  hsmInstanceIds?: [ string ](name='HsmInstanceIds'),
  ipWhiteList?: string(name='IpWhiteList'),
  masterInstanceId?: string(name='MasterInstanceId'),
  regionId?: string(name='RegionId'),
}

model CreateClusterShrinkRequest {
  clusterName?: string(name='ClusterName'),
  hsmInstanceIdsShrink?: string(name='HsmInstanceIds'),
  ipWhiteList?: string(name='IpWhiteList'),
  masterInstanceId?: string(name='MasterInstanceId'),
  regionId?: string(name='RegionId'),
}

model CreateClusterResponseBody = {
  clusterId?: string(name='ClusterId'),
  requestId?: string(name='RequestId'),
}

model CreateClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateClusterResponseBody(name='body'),
}

async function createClusterWithOptions(tmpReq: CreateClusterRequest, runtime: Util.RuntimeOptions): CreateClusterResponse {
  Util.validateModel(tmpReq);
  var request = new CreateClusterShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.hsmInstanceIds)) {
    request.hsmInstanceIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.hsmInstanceIds, 'HsmInstanceIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.clusterName)) {
    query['ClusterName'] = request.clusterName;
  }
  if (!Util.isUnset(request.hsmInstanceIdsShrink)) {
    query['HsmInstanceIds'] = request.hsmInstanceIdsShrink;
  }
  if (!Util.isUnset(request.ipWhiteList)) {
    query['IpWhiteList'] = request.ipWhiteList;
  }
  if (!Util.isUnset(request.masterInstanceId)) {
    query['MasterInstanceId'] = request.masterInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createCluster(request: CreateClusterRequest): CreateClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return createClusterWithOptions(request, runtime);
}

model CreateInstanceRequest {
  clientToken?: string(name='ClientToken', example='97C68796-EB7F-4D41-9D5B-12B909D76508'),
  hsmDeviceType?: string(name='HsmDeviceType', example='jnta.SJJ1528'),
  hsmOem?: string(name='HsmOem', example='jnta'),
  period?: int32(name='Period', example='1'),
  periodUnit?: string(name='PeriodUnit', example='Month'),
  quantity?: int32(name='Quantity', example='1'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  resourceOwnerId?: string(name='ResourceOwnerId', example='123456789'),
  zoneId?: string(name='ZoneId', example='cn-hangzhou-a'),
}

model CreateInstanceResponseBody = {
  instanceIds?: [ string ](name='InstanceIds'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model CreateInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateInstanceResponseBody(name='body'),
}

async function createInstanceWithOptions(request: CreateInstanceRequest, runtime: Util.RuntimeOptions): CreateInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.hsmDeviceType)) {
    query['HsmDeviceType'] = request.hsmDeviceType;
  }
  if (!Util.isUnset(request.hsmOem)) {
    query['HsmOem'] = request.hsmOem;
  }
  if (!Util.isUnset(request.period)) {
    query['Period'] = request.period;
  }
  if (!Util.isUnset(request.periodUnit)) {
    query['PeriodUnit'] = request.periodUnit;
  }
  if (!Util.isUnset(request.quantity)) {
    query['Quantity'] = request.quantity;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.zoneId)) {
    query['ZoneId'] = request.zoneId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createInstanceWithOptions(request, runtime);
}

model DeleteClusterRequest {
  clusterId?: string(name='ClusterId'),
}

model DeleteClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model DeleteClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteClusterResponseBody(name='body'),
}

async function deleteClusterWithOptions(request: DeleteClusterRequest, runtime: Util.RuntimeOptions): DeleteClusterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteCluster(request: DeleteClusterRequest): DeleteClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteClusterWithOptions(request, runtime);
}

model DescribeAuditLogRequest {
  describeUserOssBucket?: boolean(name='DescribeUserOssBucket'),
  regionNo?: string(name='RegionNo'),
}

model DescribeAuditLogResponseBody = {
  aliuid?: long(name='Aliuid'),
  auditOssBucket?: string(name='AuditOssBucket'),
  mgmtLogStatus?: string(name='MgmtLogStatus'),
  regionNo?: string(name='RegionNo'),
  requestId?: string(name='RequestId'),
  serviceAccessGranted?: boolean(name='ServiceAccessGranted'),
  userOssBuckets?: [ string ](name='UserOssBuckets'),
  success?: boolean(name='success'),
}

model DescribeAuditLogResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeAuditLogResponseBody(name='body'),
}

async function describeAuditLogWithOptions(request: DescribeAuditLogRequest, runtime: Util.RuntimeOptions): DescribeAuditLogResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.describeUserOssBucket)) {
    query['DescribeUserOssBucket'] = request.describeUserOssBucket;
  }
  if (!Util.isUnset(request.regionNo)) {
    query['RegionNo'] = request.regionNo;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeAuditLog',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeAuditLog(request: DescribeAuditLogRequest): DescribeAuditLogResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeAuditLogWithOptions(request, runtime);
}

model DescribeClustersRequest {
  clusterId?: string(name='ClusterId'),
  clusterName?: string(name='ClusterName'),
  clusterStatus?: string(name='ClusterStatus'),
  currentPage?: int32(name='CurrentPage'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
}

model DescribeClustersResponseBody = {
  clusters?: [ 
    {
      certificates?: {
        clusterCertificate?: string(name='ClusterCertificate'),
        clusterCsr?: string(name='ClusterCsr'),
        clusterOwnerCertificate?: string(name='ClusterOwnerCertificate'),
      }(name='Certificates'),
      clusterId?: string(name='ClusterId'),
      clusterMaster?: string(name='ClusterMaster'),
      clusterName?: string(name='ClusterName'),
      clusterSize?: string(name='ClusterSize'),
      clusterStatus?: string(name='ClusterStatus'),
      clusterZones?: [ 
        {
          vSwitchId?: string(name='VSwitchId'),
          zoneNo?: string(name='ZoneNo'),
        }
      ](name='ClusterZones'),
      createTime?: long(name='CreateTime'),
      hsmDeviceType?: string(name='HsmDeviceType'),
      ipWhiteList?: [ string ](name='IpWhiteList'),
      regionId?: string(name='RegionId'),
      vpcId?: string(name='VpcId'),
    }
  ](name='Clusters'),
  requestId?: string(name='RequestId'),
  totalCount?: string(name='TotalCount'),
}

model DescribeClustersResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeClustersResponseBody(name='body'),
}

async function describeClustersWithOptions(request: DescribeClustersRequest, runtime: Util.RuntimeOptions): DescribeClustersResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.clusterName)) {
    query['ClusterName'] = request.clusterName;
  }
  if (!Util.isUnset(request.clusterStatus)) {
    query['ClusterStatus'] = request.clusterStatus;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeClusters',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeClusters(request: DescribeClustersRequest): DescribeClustersResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeClustersWithOptions(request, runtime);
}

model DescribeInstancesRequest {
  clusterId?: string(name='ClusterId'),
  currentPage?: int32(name='CurrentPage', example='1'),
  hsmStatus?: int32(name='HsmStatus', example='1'),
  instanceId?: string(name='InstanceId', example='hsm-cn-mp90fxefc001'),
  lang?: string(name='Lang'),
  pageSize?: int32(name='PageSize', example='20'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  remark?: string(name='Remark'),
  resourceGroupId?: string(name='ResourceGroupId'),
  showInitStatus?: string(name='ShowInitStatus'),
  vpcId?: string(name='VpcId'),
  vpcIp?: string(name='VpcIp'),
}

model DescribeInstancesResponseBody = {
  instances?: [ 
    {
      clusterId?: string(name='ClusterId'),
      clusterName?: string(name='ClusterName'),
      createTime?: long(name='CreateTime', example='1514382237000'),
      digest?: string(name='Digest'),
      expiredTime?: long(name='ExpiredTime', example='1514382237000'),
      hsmDeviceType?: string(name='HsmDeviceType', example='jnta.SJJ1528'),
      hsmOem?: string(name='HsmOem', example='jnta'),
      hsmStatus?: int32(name='HsmStatus', example='1'),
      initStatus?: int32(name='InitStatus'),
      instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
      ip?: string(name='Ip', example='192.168.1.100'),
      isMaster?: boolean(name='IsMaster'),
      isTrial?: boolean(name='IsTrial'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      remark?: string(name='Remark', example='remark'),
      vpcId?: string(name='VpcId', example='vpc-lmkmivmo6'),
      vswitchId?: string(name='VswitchId', example='vsw-u7gb0qahu'),
      whiteList?: [ string ](name='WhiteList'),
      zoneId?: string(name='ZoneId', example='cn-hangzhou-a'),
    }
  ](name='Instances'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
  totalCount?: int32(name='TotalCount', example='1000'),
}

model DescribeInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeInstancesResponseBody(name='body'),
}

async function describeInstancesWithOptions(request: DescribeInstancesRequest, runtime: Util.RuntimeOptions): DescribeInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.hsmStatus)) {
    query['HsmStatus'] = request.hsmStatus;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.showInitStatus)) {
    query['ShowInitStatus'] = request.showInitStatus;
  }
  if (!Util.isUnset(request.vpcId)) {
    query['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.vpcIp)) {
    query['VpcIp'] = request.vpcIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeInstances',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeInstances(request: DescribeInstancesRequest): DescribeInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstancesWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage'),
  lang?: string(name='Lang'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      localName?: string(name='LocalName'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      zones?: [ 
        {
          cluster?: string(name='Cluster'),
          localName?: string(name='LocalName'),
          zoneId?: string(name='ZoneId', example='cn-hangzhou-a'),
        }
      ](name='Zones'),
    }
  ](name='Regions'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DescribeTrialStatusRequest {
  describeTrialResource?: boolean(name='DescribeTrialResource'),
}

model DescribeTrialStatusResponseBody = {
  aliuid?: long(name='Aliuid'),
  ifTrialAllowed?: boolean(name='IfTrialAllowed'),
  requestId?: string(name='RequestId'),
  trialResource?: map[string]object(name='TrialResource'),
  success?: boolean(name='success'),
}

model DescribeTrialStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeTrialStatusResponseBody(name='body'),
}

async function describeTrialStatusWithOptions(request: DescribeTrialStatusRequest, runtime: Util.RuntimeOptions): DescribeTrialStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.describeTrialResource)) {
    query['DescribeTrialResource'] = request.describeTrialResource;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTrialStatus',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeTrialStatus(request: DescribeTrialStatusRequest): DescribeTrialStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeTrialStatusWithOptions(request, runtime);
}

model InitializeAuditLogRequest {
  sourceIp?: string(name='SourceIp'),
}

model InitializeAuditLogResponseBody = {
  requestId?: string(name='RequestId'),
}

model InitializeAuditLogResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: InitializeAuditLogResponseBody(name='body'),
}

async function initializeAuditLogWithOptions(request: InitializeAuditLogRequest, runtime: Util.RuntimeOptions): InitializeAuditLogResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'InitializeAuditLog',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function initializeAuditLog(request: InitializeAuditLogRequest): InitializeAuditLogResponse {
  var runtime = new Util.RuntimeOptions{};
  return initializeAuditLogWithOptions(request, runtime);
}

model InitializeClusterRequest {
  clusterId?: string(name='ClusterId'),
  issuerCertificate?: string(name='IssuerCertificate'),
  signedCertificate?: string(name='SignedCertificate'),
}

model InitializeClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model InitializeClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: InitializeClusterResponseBody(name='body'),
}

async function initializeClusterWithOptions(request: InitializeClusterRequest, runtime: Util.RuntimeOptions): InitializeClusterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.issuerCertificate)) {
    query['IssuerCertificate'] = request.issuerCertificate;
  }
  if (!Util.isUnset(request.signedCertificate)) {
    query['SignedCertificate'] = request.signedCertificate;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'InitializeCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function initializeCluster(request: InitializeClusterRequest): InitializeClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return initializeClusterWithOptions(request, runtime);
}

model ModifyInstanceRequest {
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
  lang?: string(name='Lang'),
  regionId?: string(name='RegionId'),
  remark?: string(name='Remark'),
}

model ModifyInstanceResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ModifyInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ModifyInstanceResponseBody(name='body'),
}

async function modifyInstanceWithOptions(request: ModifyInstanceRequest, runtime: Util.RuntimeOptions): ModifyInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyInstance(request: ModifyInstanceRequest): ModifyInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyInstanceWithOptions(request, runtime);
}

model MoveResourceGroupRequest {
  lang?: string(name='Lang'),
  regionId?: string(name='RegionId'),
  resourceGroupId?: string(name='ResourceGroupId'),
  resourceId?: string(name='ResourceId'),
  resourceType?: string(name='ResourceType'),
}

model MoveResourceGroupResponseBody = {
  requestId?: string(name='RequestId'),
}

model MoveResourceGroupResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: MoveResourceGroupResponseBody(name='body'),
}

async function moveResourceGroupWithOptions(request: MoveResourceGroupRequest, runtime: Util.RuntimeOptions): MoveResourceGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.lang)) {
    query['Lang'] = request.lang;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'MoveResourceGroup',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function moveResourceGroup(request: MoveResourceGroupRequest): MoveResourceGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return moveResourceGroupWithOptions(request, runtime);
}

model PauseInstanceRequest {
  instanceId?: string(name='InstanceId'),
}

model PauseInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model PauseInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: PauseInstanceResponseBody(name='body'),
}

async function pauseInstanceWithOptions(request: PauseInstanceRequest, runtime: Util.RuntimeOptions): PauseInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'PauseInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function pauseInstance(request: PauseInstanceRequest): PauseInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return pauseInstanceWithOptions(request, runtime);
}

model QuickInitInstanceRequest {
  instanceId?: string(name='InstanceId'),
}

model QuickInitInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model QuickInitInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QuickInitInstanceResponseBody(name='body'),
}

async function quickInitInstanceWithOptions(request: QuickInitInstanceRequest, runtime: Util.RuntimeOptions): QuickInitInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QuickInitInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function quickInitInstance(request: QuickInitInstanceRequest): QuickInitInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return quickInitInstanceWithOptions(request, runtime);
}

model ReleaseInstanceRequest {
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
  resourceOwnerId?: string(name='ResourceOwnerId', example='1234567890'),
}

model ReleaseInstanceResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ReleaseInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ReleaseInstanceResponseBody(name='body'),
}

async function releaseInstanceWithOptions(request: ReleaseInstanceRequest, runtime: Util.RuntimeOptions): ReleaseInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ReleaseInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function releaseInstance(request: ReleaseInstanceRequest): ReleaseInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return releaseInstanceWithOptions(request, runtime);
}

model RemoveInstanceFromClusterRequest {
  clusterId?: string(name='ClusterId'),
  instanceId?: string(name='InstanceId'),
  isMaster?: boolean(name='IsMaster'),
}

model RemoveInstanceFromClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model RemoveInstanceFromClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RemoveInstanceFromClusterResponseBody(name='body'),
}

async function removeInstanceFromClusterWithOptions(request: RemoveInstanceFromClusterRequest, runtime: Util.RuntimeOptions): RemoveInstanceFromClusterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.isMaster)) {
    query['IsMaster'] = request.isMaster;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RemoveInstanceFromCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function removeInstanceFromCluster(request: RemoveInstanceFromClusterRequest): RemoveInstanceFromClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return removeInstanceFromClusterWithOptions(request, runtime);
}

model RemoveInstancesFromClusterRequest {
  clusterId?: string(name='ClusterId'),
  hsmInstanceIds?: map[string]any(name='HsmInstanceIds'),
}

model RemoveInstancesFromClusterShrinkRequest {
  clusterId?: string(name='ClusterId'),
  hsmInstanceIdsShrink?: string(name='HsmInstanceIds'),
}

model RemoveInstancesFromClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model RemoveInstancesFromClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RemoveInstancesFromClusterResponseBody(name='body'),
}

async function removeInstancesFromClusterWithOptions(tmpReq: RemoveInstancesFromClusterRequest, runtime: Util.RuntimeOptions): RemoveInstancesFromClusterResponse {
  Util.validateModel(tmpReq);
  var request = new RemoveInstancesFromClusterShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.hsmInstanceIds)) {
    request.hsmInstanceIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.hsmInstanceIds, 'HsmInstanceIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.hsmInstanceIdsShrink)) {
    query['HsmInstanceIds'] = request.hsmInstanceIdsShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RemoveInstancesFromCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function removeInstancesFromCluster(request: RemoveInstancesFromClusterRequest): RemoveInstancesFromClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return removeInstancesFromClusterWithOptions(request, runtime);
}

model RenewInstanceRequest {
  clientToken?: string(name='ClientToken', example='97C68796-EB7F-4D41-9D5B-12B909D76508'),
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8j001'),
  period?: int32(name='Period', example='1'),
  periodUnit?: string(name='PeriodUnit', example='Month'),
  resourceOwnerId?: string(name='ResourceOwnerId', example='1234567890'),
}

model RenewInstanceResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model RenewInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RenewInstanceResponseBody(name='body'),
}

async function renewInstanceWithOptions(request: RenewInstanceRequest, runtime: Util.RuntimeOptions): RenewInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.period)) {
    query['Period'] = request.period;
  }
  if (!Util.isUnset(request.periodUnit)) {
    query['PeriodUnit'] = request.periodUnit;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RenewInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function renewInstance(request: RenewInstanceRequest): RenewInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return renewInstanceWithOptions(request, runtime);
}

model ResetInstanceRequest {
  instanceId?: string(name='InstanceId'),
}

model ResetInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model ResetInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ResetInstanceResponseBody(name='body'),
}

async function resetInstanceWithOptions(request: ResetInstanceRequest, runtime: Util.RuntimeOptions): ResetInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ResetInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function resetInstance(request: ResetInstanceRequest): ResetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return resetInstanceWithOptions(request, runtime);
}

model ResetPausedInstanceRequest {
  instanceId?: string(name='InstanceId'),
}

model ResetPausedInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model ResetPausedInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ResetPausedInstanceResponseBody(name='body'),
}

async function resetPausedInstanceWithOptions(request: ResetPausedInstanceRequest, runtime: Util.RuntimeOptions): ResetPausedInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ResetPausedInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function resetPausedInstance(request: ResetPausedInstanceRequest): ResetPausedInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return resetPausedInstanceWithOptions(request, runtime);
}

model ResumeInstanceRequest {
  instanceId?: string(name='InstanceId'),
}

model ResumeInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model ResumeInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ResumeInstanceResponseBody(name='body'),
}

async function resumeInstanceWithOptions(request: ResumeInstanceRequest, runtime: Util.RuntimeOptions): ResumeInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ResumeInstance',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function resumeInstance(request: ResumeInstanceRequest): ResumeInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return resumeInstanceWithOptions(request, runtime);
}

model SwitchClusterMasterRequest {
  clusterId?: string(name='ClusterId'),
  instanceId?: string(name='InstanceId'),
}

model SwitchClusterMasterResponseBody = {
  requestId?: string(name='RequestId'),
}

model SwitchClusterMasterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SwitchClusterMasterResponseBody(name='body'),
}

async function switchClusterMasterWithOptions(request: SwitchClusterMasterRequest, runtime: Util.RuntimeOptions): SwitchClusterMasterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SwitchClusterMaster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function switchClusterMaster(request: SwitchClusterMasterRequest): SwitchClusterMasterResponse {
  var runtime = new Util.RuntimeOptions{};
  return switchClusterMasterWithOptions(request, runtime);
}

model SyncInClusterRequest {
  clusterId?: string(name='ClusterId'),
}

model SyncInClusterResponseBody = {
  requestId?: string(name='RequestId'),
}

model SyncInClusterResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SyncInClusterResponseBody(name='body'),
}

async function syncInClusterWithOptions(request: SyncInClusterRequest, runtime: Util.RuntimeOptions): SyncInClusterResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clusterId)) {
    query['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SyncInCluster',
    version = '2018-01-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function syncInCluster(request: SyncInClusterRequest): SyncInClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return syncInClusterWithOptions(request, runtime);
}

